// 获取ip地址
const getIpAddress = () => {
  let ipAddress = '';
  let interfaces = require('os').networkInterfaces();
  Object.keys(interfaces).map(key => {
    let iface = interfaces[key];
    for(let i = 0; i < iface.length; i += 1) {
      let alias = iface[i];
      if(alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
        ipAddress = alias.address;  break;
      } 
    }
  });
  return ipAddress;
}

module.exports = getIpAddress;